<?php if (!defined("_ECRIRE_INC_VERSION")) return;

/**
 *  Dymanic Tag wich outputs product price according to product's or given currency
 *  Format: #ECATALOGUE_PRODUCT_PRICE{<id_article>[, <currency_code>][, <type>]}
 *      If you want to output price in product's currency, dont specify currency_code
 *      If you want to output not standart price, specify it's type (<type>), i.e. type="priceold"
 */

function balise_ECATALOGUE_PRODUCT_PRICE($p) {	
	return calculer_balise_dynamique($p,'ECATALOGUE_PRODUCT_PRICE', array());
}

function balise_ECATALOGUE_PRODUCT_PRICE_stat($args, $filtres) {    
	return $args;
}

function balise_ECATALOGUE_PRODUCT_PRICE_dyn($id_article, $currency_code = false, $type = 'price') { //var_dump($id_article);
    require_once(_DIR_PLUGIN_ECATALOGUE.'classes/class.ProductModel.php');
    $product_mdl = new ProductModel();
    
    // If some exceptions are thrown - return empty value 
    try {
        $price = $product_mdl->GetProductPrice($id_article, $currency_code, $type);
    } catch (Exception $e) {
        $price = '';
    } 
    
    return array('balise/ecatalogue_product_price', 3600, 
		array('price' => $price            
    ));
}

?>